package com.struts.deal.corpor.register;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.base.BaseLog;
import com.ibatis.po.corpor.TCorporationExample;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.lg.system.CSqlMap;

public class AjaxDeal {
     
	/**
	 * 检查用户名是否存在
	 * @param request
	 * @param response
	 */
	public static  void checkLoginName(HttpServletRequest request,
            HttpServletResponse response){
		SqlMapClient sqlmap=CSqlMap.getSqlMapConfig();
		TCorporationExample corporEp = new TCorporationExample();
		
    	try{
        	String lname= "";
        	String lnametemp= request.getParameter("lname");
        	if(lnametemp.length()>0 && lnametemp != null){
        		lname=lnametemp;
        	}
        	response.setCharacterEncoding("UTF-8");
        	PrintWriter out = response.getWriter();
        	int count = 0;
        	corporEp.createCriteria().andLoginNameEqualTo(lname);
        	count = ((Integer)sqlmap.queryForObject("T_CORPORATION.abatorgenerated_countByExample",corporEp)).intValue();
        	BaseLog.logger.info("dddddd:"+count);
        	if(count>0){
        		
        		out.print("对不起，该用户已被使用！");
        	}else{
        		out.print("恭喜你，该用户未被使用！");
        	}
        	}catch(Exception e){
        		e.printStackTrace();
        	}
    	
    	
    }
	
	
}
